package com.chanel.iamframework.core.service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.chanel.iamframework.core.domain.Role;
import com.chanel.iamframework.validation.annotation.Validate;

@Validate
public interface RoleService {

	/**
	 * Persist Role entity
	 * @param role entity
	 * @return true if the object is persisted, false otherwise.
	 */
	void createRole(@NotNull @Valid Role role);
	
	/**
	 * Get Role by Identity
	 * @param roleId entity
	 * @return Role entity
	 */
	Role getRole(@NotNull Long roleId);

	/**
	 * Update Role entity
	 * @param role entity
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean updateRole(@NotNull @Valid Role role);
	
	/**
	 * Delete Role entity
	 * @param roleId Identity
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteRole(@NotNull Long roleId);

	/**
	 * Load Groups by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	Role loadGroups(@NotNull Long roleId);

	/**
	 * Load Application by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	Role loadApplications(@NotNull Long roleId);

	/**
	 * Load User by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.User}
	 */
	Role loadUsers(@NotNull Long roleId);
	
	/**
	 * Add Role, Groups association
	 * @param role {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	void addGroups(@NotNull Role role);

	/**
	 * Delete Role, Groups association
	 * @param role {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteGroups(@NotNull Role role);
}
